<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('title'); ?>
	Edit <?php echo $name;?>
<?php $this->_endblock(); ?>

<?php $this->_block('contents'); ?>
<div id="content" class="box">
	<h1>Edit Creative</h1>
		<fieldset>
			<legend>Edit <?php echo $name;?></legend>
		<?php if (isset($errors)) 
				{
					foreach ($errors as $error)
					{
		?>
				<p class="msg error"><?php echo $error;?></p>
		<?php		}
				}
		?>
		<form method="POST" action="<?php echo url('creative/edit');?>">
		<input type="hidden" name="id" value="<?php echo $id;?>"/>
		<table class="nostyle">
			<tr>
				<td>Name:</td>
				<td><input type="text" class="input-text" name="name" value="<?php if (isset($name)) echo $name;?>"/></td>
			</tr>
			<tr>
				<td>Type:</td>
				<td>
					<select name="type" id="type">
						<option value="1" <?php echo ('1' == $type) ?  'selected="selected"' : ''; ?>>Image</option>
						<option value="2" <?php echo ('2' == $type) ?  'selected="selected"' : ''; ?>>Flash</option>
						<option value="3" <?php echo ('3' == $type) ?  'selected="selected"' : ''; ?>>Email</option>
					</select>
				</td>
			</tr>
			<tr id="size">
				<td>Size:</td>
				<td>
					<select name="size">
						<option value="1" <?php echo ('1' == $size) ?  'selected="selected"' : ''; ?>>Medium Rectangle (300 x 250)</option>
						<option value="2" <?php echo ('2' == $size) ?  'selected="selected"' : ''; ?>>Rectangle (180 x 150)</option>
						<option value="3" <?php echo ('3' == $size) ?  'selected="selected"' : ''; ?>>Leaderboard (728 x 90)</option>
						<option value="4" <?php echo ('4' == $size) ?  'selected="selected"' : ''; ?>>Wide Skyscraper (160 x 600)</option>
						<option value="5" <?php echo ('5' == $size) ?  'selected="selected"' : ''; ?>>Half Page Ad (300 x 600)</option>
						<option value="6" <?php echo ('6' == $size) ?  'selected="selected"' : ''; ?>>Button 2 (120 x 60)</option>
						<option value="7" <?php echo ('7' == $size) ?  'selected="selected"' : ''; ?>>Micro Bar (88 x 31)</option>
					</select>
				</td>
			</tr>
			<tr id="url">
				<td>URL:</td>
				<td><input type="text" class="input-text" name="url" value="<?php if (isset($url)) echo $url;?>"/></td>
			</tr>
			<tr id="html">
				<td>HTML:</td>
				<td><textarea name="html"><?php echo isset($html) ? $html : ''; ?></textarea></td>
			</tr>
			<tr>
				<td colspan="2" class="t-right"><input type="submit" class="input-submit" value="Update"/></td>
			</tr>
		</table>
		</form>
	</fieldset>
</div>
<script type="text/javascript">
	$(function(){
		<?php if(3 == $type): ?>
			$('#url').hide();
			$('#size').hide();
		<?php else: ?>
			$('#html').hide();
		<?php endif; ?>
		$('#type').change(function(){
			$type = $('#type').val();
			if($type == 1 || $type == 2){
				$('#html').hide();
				$('#url').show();
				$('#size').show();
			}else if($type == 3) {
				$('#html').show();
				$('#url').hide();
				$('#size').hide();
			} 
		});
	});
</script>
<?php $this->_endblock(); ?>
